package edu.cmu.cs.webapp.ioms.ui.wizards.user;

import org.eclipse.jface.wizard.Wizard;

import edu.cmu.cs.webapp.ioms.models.Client;
import edu.cmu.cs.webapp.ioms.models.User;
import edu.cmu.cs.webapp.ioms.models.impl.IOMSFactoryImpl;

/**
 * 
 * @author Christian
 */
public class UserWizard extends Wizard {
	private UserWizardPage _mainPage;
	private boolean _isUpdate;
	private User _model;

	public UserWizard(boolean update, User model) {
		_isUpdate = update;
		this._model = model;
	}

	@Override
	public void addPages() {
		_mainPage = new UserWizardPage("General Page");
		addPage(_mainPage);
	}

	@Override
	public boolean performFinish() {
		if (_model == null) {
			_model = IOMSFactoryImpl.eINSTANCE.createUser();
		}
		_model.setLogin(_mainPage.getLogin());
		_model.setName(_mainPage.getName());
		_model.setRole(_mainPage.getRole());
		_model.setPassword(_mainPage.getInitialPassword());
		_model.setDepartment(_mainPage.getDepartment());

		return true;
	}

	public User getModel() {
		return this._model;
	}

	public boolean isUpdate() {
		return _isUpdate;
	}

}
